app.service('shopLocatedEditService',['$http','$q','utilService',function($http,$q,utilService){
    this.findById = function($scope){
        var deferred = $q.defer();
        utilService.get({
            url:$scope.app.domain + 'shop/located/info/'+ $scope.id,
            params:{id:$scope.id}
        }).then(function(response){
            deferred.resolve(response.data);
        },function(e){
            console.error(e);
            deferred.reject("连接服务器出错！");
        });
        return deferred.promise;
    }
    this.queryShop = function($scope){
        var deferred = $q.defer();
        utilService.get({
            url:$scope.app.domain + 'shop/concise',
            params:{}
        }).then(function(response){
            deferred.resolve(response.data);
        },function(e){
            console.error(e);
            deferred.reject("连接服务器出错！");
        });
        return deferred.promise;
    }
    this.obtainedMeal = function($scope){
        var deferred = $q.defer();
        utilService.get({
            url:$scope.app.domain + 'set/meal/concise',
            params:{}
        }).then(function(response){
            deferred.resolve(response.data);
        },function(e){
            console.error(e);
            deferred.reject("连接服务器出错！");
        });
        return deferred.promise;
    }
    this.submit = function($scope){
        var deferred = $q.defer();
        utilService.api({
            url:$scope.app.domain + 'shop/located',
            data:$scope.shopLocated,
            method:'PUT'
        }).then(function(response){
            deferred.resolve(response.data);
        },function(e){
            deferred.reject("连接服务器出错！");
        });
        return deferred.promise;
    }
    /*
        source:源对象
        aims：目标对象
        没有改动将返回false
    */
    this.comparing = function(source,aims){
        var boo = false;
        for(var key in source) {
           if(aims[key] != source[key]){
                boo = true;
                break;
           }
       };
       return boo;
    }
}]);